<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>users</title>
<jsp:include page="header.jsp"></jsp:include>

<script type="text/javascript" charset="utf-8" src="../ueditor/utf8-jsp/ueditor.config.js"></script>  
<script type="text/javascript" charset="utf-8" src="../ueditor/utf8-jsp/ueditor.all.min.js"> </script>  
<script type="text/javascript" charset="utf-8" src="../ueditor/utf8-jsp/lang/zh-cn/zh-cn.js"></script>   
<script type="text/javascript">
var ue = UE.getEditor('content');

$(function(){
	//分页显示用户列表
	$('#dg').datagrid({    
	    url:'../shop/show', 
	   		title:'商铺列表',
			iconCls:'icon-save',
			fitColumns:true,
			striped:true,
			pagination:true,
			rownumbers:true,
			fit:true,
			columns:[[
			{field:'spic',title:'商铺头像',width:50,height:80,align:'left',
		        formatter:function(value, rec){//使用formatter格式化刷子
		        	return '<img src='+'../images/'+value+'>';
		        }},
		    {field:'sid',title:'商铺ID',width:100}, 
	        {field:'sname',title:'商铺名称',width:100},    
	        {field:'summary',title:'商品简介',width:100},
	        {field:'pid',title:'供应商ID',width:100}
	    ]], 
	     toolbar: [{
			iconCls: 'icon-add',
			handler: addGoods,
			text:'在店铺中添加商品',
		}] 
	}) 
	
});
	//1.添加操作，添加先显示对话框让用户输入
	function addGoods(){
		//打开窗口
		//清空form
		$("#addDialog #ff").form("clear");
		/* var con=$("#addDialog #ff #content").attr(value,""); */
		$("#addDialog").dialog("open");
	 	$("#count").numberspinner("setValue",1000);
	 	$("#minorder").numberspinner("setValue",100);
		var selectedrow=$("#dg").datagrid("getSelected");
		//给sid赋值
		$("#addDialog #ff #sid").attr("value",selectedrow.sid);
		var as=$("#addDialog #ff #sid").val();
		//alert(as);
		
		$("#addDialog #ff #fileName").filebox({    
		    buttonText: '选择文件', 
		    buttonAlign: 'left' 
		})
		$("#addDialog #ff #fileName_1").filebox({    
		    buttonText: '选择文件', 
		    buttonAlign: 'left' 
		})
		$("#addDialog #ff #fileName_2").filebox({    
		    buttonText: '选择文件', 
		    buttonAlign: 'left' 
		})
		$("#addDialog #ff #fileName_3").filebox({    
		    buttonText: '选择文件', 
		    buttonAlign: 'left' 
		})
	}
	 //关闭新增窗口
	function closeAddDialog(){
		$("#addDialog").dialog("close");
	}
//保存新增数据
	function addSubmit(){
		$("#addDialog #ff").form('submit', {    
		    url:'../goods/add',   
		    onSubmit: function(){    
		        // 做一些验证，提交数据是否合法
		        return $(this).form('validate');
	
		        // return false to prevent submit;    
		    },    
		    success:function(data){ //这个data不是json对象而是一个字符串 
		    	var message=JSON.parse(data);	    
		    	$.messager.show({
					title:'提示消息',
					msg:message.msg,
					timeout:2000,
					showType:'slide'
				});
		    	if(message.success){
		    		$("#dg").datagrid("reload");
		    		$("#addDialog").dialog("close");
		    	}    
		    }    
		});  
	}
</script>
</head>
<body>
	<table id="dg"></table>
	<div id="addDialog" class="easyui-dialog" title="新增商品" style="width:1600px;padding:10px;"   
        data-options="iconCls:'icon-save',resizable:true,closed:true,buttons:[{
				text:'保存',
				handler:addSubmit
			},{
				text:'关闭',
				handler:closeAddDialog
			}]">

    <form id="ff" method="post" enctype="multipart/form-data">
    <input type="hidden" id="sid" name="sid" >
    <textarea name="content" id="content" style="width:1500px; height:300px; margin: 0 auto;"></textarea>
   	<table style="width:100%;">		
    	<tr>
	    	<td>商品名称:</td>
	    	<td>
	    	<input class="easyui-textbox" name="gname" style="width:300px; text-align:left;" data-options="required:true,validType:'length[2,15]'">
	    	</td>
	    	<td>商品价格:</td>
	    	<td>
	    	<input class="easyui-textbox" name="price" style="width:300px; text-align:left;" data-options="required:true,validType:'length[1,15]'">
	    	</td>
	    	<td>商品库存:</td>
	    	<td>
	    	<input id="count" class="easyui-numberspinner" name="count" data-options="increment:100" style="width:300px;"></input>    	
	    	</td>
	    	<td>商品简介:</td>
	    	<td>
	    	<input class="easyui-textbox" name="summary" style="width:300px; text-align:left;" data-options="required:true,validType:'length[4,225]'">
	    	</td>
    	</tr>
    	<tr>
	    	<td>生产厂家:</td>
	    	<td>
	    	<input class="easyui-textbox" name="factory" style="width:300px" data-options="required:true,validType:'length[2,15]'">
	    	</td>
	    	<td>最低起定量:</td>
	    	<td>
	    	<!-- <input class="easyui-textbox" name="minorder" style="width:300px" data-options="required:true,validType:'length[1,15]'"> -->
	    	<input id="minorder" class="easyui-numberspinner" name="minorder" value="100" data-options="increment:10" style="width:300px;"></input>
	    	</td>
	    	<td>商品规格:</td>
	    	<td>
	    	<input class="easyui-textbox" name="spec" style="width:300px" data-options="required:true,validType:'length[1,15]'">
	    	</td>
	    	<td>药品类别:</td>
	    	<td>
	    	<select id="gclass" name="gclass" class="easyui-combobox"  style="width:300px;" required="true">  
			   <option value="处方药" selected="selected">处方药</option>  
			   <option value="非处方药">非处方药</option>  
			</select>
	    	</td>
    	</tr>
    	<tr>
	    	<td>商品主图:</td>
	    	<td>
	    	<input type="text" id="fileName" name="fileName" style="width:300px" data-options="required:true">
	    	</td>
	    	<td>商品详图1:</td>
	    	<td>
	    	<input type="text" id="fileName_1" name="fileName_1" style="width:300px" data-options="required:true">
	    	</td>
	    	<td>商品详图2:</td>
	    	<td>
	    	<input type="text" id="fileName_2" name="fileName_2" style="width:300px" data-options="required:true">
	    	</td>
	    	<td>商品详图3:</td>
	    	<td>
	    	<input type="text" id="fileName_3"name="fileName_3" style="width:300px" data-options="required:true">
	    	</td>
    	</tr>
    	<tr>
	    	
	    <td>商品状态</td>
	    <td>
	    	<select id="state" name="state" class="easyui-combobox"  style="width:300px;" required="true">  
			   <option value="1" selected="selected">正常上架商品</option>  
			   <option value="2">已下架商品</option>  
			   <option value="3">商铺首页展示商品</option>  
			   <option value="4">商铺首页促销商品</option>  
			</select>
	    </td>
	    <td>所属分类</td>
	    <td>
	    	<select id="type_id" name="type_id" class="easyui-combobox"  style="width:300px;" required="true">  
			   <option value="24" selected="selected">糖尿病</option>  
			   <option value="25">甲状腺疾病</option>  
			   <option value="26">胆道疾病</option>  
			   <option value="27">脂肪肝</option>  
			   <option value="28">免疫调节</option>  
			   <option value="29">乙肝</option>  
			   <option value="30">神经损伤</option>  
			   <option value="31">头疼偏头疼</option>  
			   <option value="32">焦虑症</option>  
			   <option value="33">多动症</option>  
			   <option value="34">抑郁症</option>  
			   <option value="35">戒烟</option>  
			   <option value="36">失眠</option>  
			   <option value="37">癫痫</option>  
			   <option value="38">面瘫</option>  
			   <option value="39">中风</option>  
			   <option value="40">脑血管病</option>  
			   <option value="41">心律失常</option>  
			   <option value="42">心肌炎</option>  
			   <option value="43">动脉硬化</option>  
			   <option value="44">静脉曲张</option>  
			   <option value="45">心绞痛</option>  
			   <option value="46">冠心病</option>  
			   <option value="47">高血脂</option>  
			   <option value="48">高血压</option>  
			   <option value="49">口腔溃疡</option>  
			   <option value="50">牙周疼痛</option>  
			   <option value="51">咽喉炎</option>  
			   <option value="52">耳聋耳鸣</option>  
			   <option value="53">青光眼</option>  
			   <option value="54">白内障</option>  
			   <option value="55">眼干眼涩</option>  
			   <option value="56">眼部炎症</option>  
			   <option value="57">鼻炎</option>  
			   <option value="58">过敏</option>  
			   <option value="59">蚊虫叮咬</option>  
			   <option value="60">烫伤创伤</option>  
			   <option value="61">艾滋病</option>  
			   <option value="62">黄褐斑</option>  
			   <option value="63">系统性红斑狼疮</option>  
			   <option value="64">尖锐湿疣</option>  
			   <option value="65">疱疹</option>  
			   <option value="66">脱发</option>  
			   <option value="67">白癜风</option>  
			   <option value="68">升白升血小板</option>  
			   <option value="69">癌症止痛止呕</option>  
			   <option value="70">化疗提高营养学</option>  
			   <option value="71">甲状腺瘤</option>  
			   <option value="72">乳腺癌</option>  
			   <option value="73">白血病</option>  
			   <option value="74">淋巴癌</option>  
			   <option value="75">食道癌</option>  
			   <option value="76">胃癌</option>  
			   <option value="77">器官移植</option>  
			   <option value="78">跌打骨伤</option>  
			   <option value="79">外用膏药</option>  
			   <option value="80">骨质疏松</option>  
			   <option value="81">颈椎病</option>  
			   <option value="82">骨质增生</option>  
			   <option value="83">关节炎</option>  
			   <option value="84">疼痛用药</option>  
			   <option value="85">风湿类风湿</option>  
			   <option value="86">痛风</option>  
			   <option value="87">营养剂</option>  
			   <option value="88">小儿肠胃病</option>  
			   <option value="89">蛔虫病</option>  
			   <option value="90">痔疮</option>  
			   <option value="91">腹泻</option>  
			   <option value="92">胃肠溃疡</option>  
			   <option value="93">消化不良</option>  
			   <option value="94">结肠炎</option>  
			   <option value="95">便秘</option>  
			   <option value="96">胃炎</option>  
			   <option value="97">更年期</option>  
			   <option value="98">孕产期</option>  
			   <option value="99">避孕</option>  
			   <option value="100">妇科炎症</option>  
			   <option value="101">慢阻肺</option>  
			   <option value="102">支气管炎</option>  
			   <option value="103">哮喘</option>  
			   <option value="104">小儿感冒</option>  
			   <option value="105">上火</option>  
			   <option value="106">咳嗽</option>  
			   <option value="107">感冒发烧</option>  
			   <option value="108">泌尿系统疾病</option>  
			   <option value="109">肾病</option>  
			   <option value="110">前列腺炎</option>  
			   <option value="111">男性不育症</option>  
			   <option value="112">性功能障碍</option>  
			   <option value="113">免疫调节</option>  
			   <option value="114">补肾</option>  
			   <option value="115">减肥瘦身</option>  
			   <option value="116">安神助眠</option>  
			   <option value="117">增强抵抗力</option>  
			   <option value="118">补血补气</option>  
			</select>
	    </td>
	    <td>所属首页商品栏目</td>
	    <td>
	    	<select id="index_id" name="index_id" class="easyui-combobox"  style="width:300px;" required="true">  
			   <option value="1" selected="selected">正常商品</option>  
			   <option value="2">限时促销</option>  
			   <option value="3">季节精选</option>  
			   <option value="4">日常用药</option>  
			   <option value="5">慢性疾病</option>  
			   <option value="6">医疗器械</option>  
			   <option value="7">保健用品</option>  
			</select>
	    </td>
	    <td>商品所在区域</td>
	    <td>
	    	<select id="address_id" name="address_id" class="easyui-combobox"  style="width:300px;" required="true">  
			   <option value="1" selected="selected">华北</option>  
			   <option value="2">东北</option>  
			   <option value="3">华东</option>  
			   <option value="4">华中</option>  
			   <option value="5">西南</option>  
			   <option value="6">西北</option>  
			</select>
	    </td>
    	</tr>
    </table>
	</form>
	</div>  
	
</body>
</html>